package org.apereo.cas.web.y9.util;

import java.nio.charset.StandardCharsets;

import org.apache.commons.codec.binary.Base64;

public class Y9Base64 {

    public static String decode(String encryptedText) {
        Base64 dec = new Base64(-1);
        byte[] bTemp = dec.decode(encryptedText);
        String str = new String(bTemp, StandardCharsets.UTF_8);
        return str;
    }

    public static String encode(String plainText) {
        Base64 encoder = new Base64(-1);
        String str = encoder.encodeToString(plainText.getBytes());
        return str;
    }

    public static void main(String[] args) {
        String str = "111111";
        String enc = Y9Base64.encode(str); // MTExMTEx
        String dec = Y9Base64.decode(enc);
        System.out.println(enc);
        System.out.println(dec);
    }
}
